﻿using System;
using RpcClient;
using Wedonek.RpcStore.Gateway.Interface;
using Wedonek.RpcStore.Gateway.Model;
using Wedonek.RpcStore.Service.Interface;
using Wedonek.RpcStore.Service.Model;

namespace Wedonek.RpcStore.Gateway.Service
{
        internal class AutoTaskPlanService : IAutoTaskPlanService
        {
                private readonly IAutoTaskPlanCollect _TaskPlan = null;

                public AutoTaskPlanService (IAutoTaskPlanCollect plan)
                {
                        this._TaskPlan = plan;
                }
                public void SetIsEnable (Guid id, bool isEnable)
                {
                        AutoTaskPlan plan = this._TaskPlan.Get (id);
                        this._TaskPlan.SetIsEnable (plan, isEnable);
                }
                public Guid Add (AddTaskPlan plan)
                {
                        AutoTaskPlan add = plan.ConvertMap<AddTaskPlan, AutoTaskPlan> ();
                        add.InitPlanShow ();
                        add.InitPlanOnlyNo ();
                        return this._TaskPlan.Add (add);
                }

                public void Delete (Guid id)
                {
                        AutoTaskPlan plan = this._TaskPlan.Get (id);
                        this._TaskPlan.Delete (plan);
                }

                public AutoTaskPlan Get (Guid id)
                {
                        return this._TaskPlan.Get (id);
                }

                public AutoTaskPlan[] Gets (Guid taskId)
                {
                        return this._TaskPlan.Gets (taskId);
                }

                public void Set (Guid id, TaskPlanSet set)
                {
                        AutoTaskPlan plan = this._TaskPlan.Get (id);
                        set.InitPlanOnlyNo ();
                        this._TaskPlan.Set (plan, set);
                }
        }
}
